package cn.xiaopengstack.infrastructure.persistent.dao;

import cn.bugstack.middleware.db.router.annotation.DBRouter;
import cn.xiaopengstack.domain.activity.model.entity.RaffleActivityAccountEntity;
import cn.xiaopengstack.infrastructure.persistent.po.RaffleActivityAccount;
import cn.xiaopengstack.infrastructure.persistent.po.UserRaffleOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
* @author jiangyangang
* @description 针对表【raffle_activity_account(抽奖活动账户表)】的数据库操作Mapper
* @createDate 2025-06-24 10:48:42
* @Entity cn.xiaopengstack.infrastructure.persistent.po.RaffleActivityAccount
*/
@Mapper
public interface IRaffleActivityAccountDao {

    /**
     * 查询用户活动账户
     * @param raffleActivityAccount
     * @return
     */
    @DBRouter(key = "userId")
    RaffleActivityAccount queryActivityAccount(RaffleActivityAccount raffleActivityAccount);

    /**
     * 插入用户活动账户
     * @param raffleActivityAccount
     */
    @DBRouter(key = "userId")
    void insertSelective(RaffleActivityAccount raffleActivityAccount);

    /**
     * 更新账户
     * @param raffleActivityAccount
     * @return
     */
    @DBRouter(key = "userId")
    int updateAccountQuota(RaffleActivityAccount raffleActivityAccount);

    /**
     * 更新镜像库存
     * @param userId
     * @param activityId
     * @return
     */
    @DBRouter
    int updateActivityAccountSubtractionQuota(@Param("userId") String userId,
                                              @Param("activityId") Long activityId,
                                              @Param("decrNumber") Integer decrNumber);

    /**
     * 更新月库存镜像
     * @param userId
     * @param activityId
     * @param monthCountSurplus
     * @return
     */
    @DBRouter
    int updateActivityAccountMonthSurplusImageQuota(@Param("userId") String userId,
                                                    @Param("activityId") Long activityId,
                                                    @Param("monthCountSurplus") Integer monthCountSurplus,
                                                    @Param("decrNumber") Integer decrNumber);

    /**
     * 更新日库存镜像
     * @param userId
     * @param activityId
     * @param dayCountSurplus
     * @return
     */
    @DBRouter
    int updateActivityAccountDaySurplusImageQuota(@Param("userId") String userId,
                                                  @Param("activityId") Long activityId,
                                                  @Param("dayCountSurplus") Integer dayCountSurplus,
                                                  @Param("decrNumber") Integer decrNumber);

}




